<html>
	<head>
		<meta http-equiv="content-type" content="text/html;charset=utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width,initial-scale=1">
		<title><?php echo $header['title']; ?></title>
		<meta name="description" content="<?php echo $header['description']; ?>">
		<meta name="keywords" content="<?php echo $header['keywords']; ?>">
		<link href="view/css/bootstrap.css" type="text/css" rel="stylesheet">
		<link href="view/css/login.css" type="text/css" rel="stylesheet">
	</head>

	<body>
		<div id="login">
			<div class="logo text-center">
				<a href="/">
					<img src="view/img/logo.png">
				</a>
			</div>
			<div class="box">
				<div class="title">
					用户登录
				</div>
				<div class="content">
					<form class="form-ajax" action="<?php echo url('user-login');?>" method="post">
						<div class="form-group">
							<input type="text" id="username" class="form-control" placeholder="用户名" maxlength="50" required="">
						</div>
						<div class="form-group">
							<input type="password" id="password" class="form-control" placeholder="密码" maxlength="50" required="">
						</div>
						<div class="form-group">
							<input type="text" id="vcode" class="form-control" placeholder="验证码" maxlength="5" required="">
							<div style="background:#fff;border:1px solid #e5e5e5;border-top:0;padding:5px 0;border-radius:3px;text-align:center">
								<img src="<?php echo url('index-vcode');?>" onclick="javascript:this.src=this.src+'?t=new Date().getTime()'" class="imgcode" style="cursor:pointer;">
							</div>
						</div>
						<div class="form-group">
							<button type="submit" class="btn btn-success btn-block" id="reg">
								立即登录
							</button>
						</div>
					</form>
				</div>
			</div>
			<div class="ltip">
				<a href="<?php echo url('user-register');?>">
					如果您没有账号，请点此注册
				</a>
			</div>
		</div>
        <script src="view/js/jquery.min.js" type="text/javascript"></script>
		<script src="view/js/bootstrap.js" type="text/javascript"></script>
		<script>
			$('#reg').click(function(){
				var $this = $(this);
				$this.attr('disabled', '1');
				var username = $('#username').val();
				var password = $('#password').val();
				var vcode = $('#vcode').val();
				if(username=='' || password=='' || vcode=='') {
					alert('信息不能为空');
					$this.attr('disabled', false);
				}else{
					var postdata = {username:username, password:password, vcode:vcode};
					$.post($('.form-ajax').attr('action'), postdata, function(message){
						alert(message.message);
						$this.attr('disabled', false);
						if(message.code==1) window.location.href = "<?php echo url('user-center');?>";
					}, 'json');
				}
				return false;
			});
		</script>
	</body>
</html>